perm filename CONCEP.DIF[CLS,LSP]1 blob sn#832569 filedate 1987-01-16 generic text, type T, neo UTF8
  1) CONCEP.TEX[CLS,LSP] and 2) CONCEP.8[CLS,LSP]	1-16-87 12:39	pages 1,1

**** File 1) CONCEP.TEX[CLS,LSP]/1P/309L
1)	\endsubSection%{Defining Classes}
1)	\beginsubSection{The Structure of Instances}
**** File 2) CONCEP.8[CLS,LSP]/1P/309L
2)	\endsubSection
2)	\beginsubSection{The Structure of Instances}
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/343L
1)	%[I don't think we need this section.  -Sonya]
**** File 2) CONCEP.8[CLS,LSP]/1P/342L
2)	\beginsubSection{Inheritance}
2)	A class inherits slots and methods from its superclasses.  Inheritance is
2)	the key to program modularity within \CLOS.  A typical object-oriented
2)	program consists of several classes, each of which defines some aspect of
2)	behavior.  New classes are defined by including the appropriate classes as
2)	superclasses, thus gathering desired aspects of behavior into one
2)	class.
2)	Slots and methods are inherited according to the class precedence list,
2)	which is an ordered list of the classes above the given class.
2)	The most specific element in the class precedence list is always
2)	the class itself.  This allows the class to override a slot description or
2)	method inherited from any of its superclasses.
2)	The inheritance of methods is described in detail in the section 
2)	``Method Selection and Combination.''   
2)	\endsubSection%{Inheritance}
2)	%[I don't think we need this section.  -Sonya]
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/707L
1)	\beginSection{Inheritance}
1)	Inheritance is the key to program modularity within \CLOS.  A typical
1)	object-oriented program consists of several classes, each of which
1)	defines some aspect of behavior.  New classes are defined by including
1)	the appropriate classes as superclasses, thus gathering desired aspects
1)	of behavior into one class.
1)	A class inherits methods, slots, and some {\bf defclass} options from all of
1)	its superclasses.  However, the class can choose to override an 
1)	inherited method, slot, or {\bf defclass} option.  This section describes what
1)	is inherited from superclasses, and how a class can override an aspect
1)	of inherited behavior.  
1)	 
1)	\beginsubSection{Inheritance of Methods}
1)	In general, methods are inherited by subclasses.   That is, a method provided by a
1)	class is applicable for use on instances of any subclass of that 
1)	class.   In some cases, an inherited method can be shadowed by providing
  1) CONCEP.TEX[CLS,LSP] and 2) CONCEP.8[CLS,LSP]	1-16-87 12:39	pages 1,1

1)	a method for a more specific class.   When standard method combination
1)	is used, the primary method can be shadowed by a method on a more
1)	specific class.   (However, if the more specific method uses
1)	{\bf call-next-method}, the next most specific primary method is called.)
1)	The inheritance of methods acts the same way regardless of whether the 
1)	method was created using {\bf defmethod} or by using one of the {\bf defclass} 
1)	options that cause methods to be generated automatically (for reading or 
1)	accessing the value of a slot). 
1)	The inheritance of methods is described in detail in the section
1)	``Method Selection and Combination.''   
1)	\endsubSection%{Inheritance of Methods}
1)	\beginsubSection{Inheritance of Slots}
1)	In general, slots are inherited by subclasses.   That is, slots defined in 
1)	a class are usually also slots in any subclass of that class. 
1)	The inheritance of slots
1)	depends on whether the inherited slot is allocated by {\bf :class} or
1)	{\bf :instance}, and whether the {\bf :allocation} slot option is given in the local
1)	slot-description.   One important rule is that 
1)	an instance has at most one slot by any given name accessible to it. 
1)	There are several different cases:
1)	1.  In the simplest case, a class does not provide a local description
1)	of a slot with the same name as a slot provided by its superclass.  If 
1)	it is an {\bf :instance} slot, the subclass allocates storage for it in each
1)	instance.  If it is a {\bf :class} slot, the allocation of the slot is done by 
1)	the superclass, and that single slot is accessible by instances of both 
1)	the superclass and the subclass.  
1)	2.  Whenever a class specifies {\bf :allocation} {\bf :class},
1)	a new {\bf :class} slot is created, and any slot with that name provided 
1)	by a superclass is not accessible to instances of this class.
1)	3.  Whenever a class specifies {\bf :allocation} :none for a slot, no slot
1)	with that name is accessible to instances of this class.  Thus, the
1)	{\bf :allocation} :none option allows for subtractive inheritance; a class can
1)	specify {\bf :allocation} :none to prevent access to a slot supplied by a 
1)	superclass.
1)	4.  Whenever a class provides a local description of an {\bf :instance} slot,
1)	and its superclass provides a description of a {\bf :class} slot with  
1)	the same name, only the {\bf :instance} slot that was described locally
1)	is accessible to the subclass.   Only the {\bf :class} slot is accessible  
1)	instances of the superclass.   (Note that the {\bf defclass} default {\bf :allocation}
1)	is {\bf :instance}, so a slot description is treated as an {\bf :instance} slot 
1)	if the {\bf :allocation} option is not explicitly supplied.)
1)	5.  Whenever a class provides a local description of an {\bf :instance} slot,
1)	and its superclass also provided a description of an {\bf :instance} slot with
1)	the same name, the effect of the local slot description is to override
1)	or alter some of the inherited characteristics of the slot, such as its
1)	{\bf :initform} or {\bf :type} options.  (The inheritance behavior of each {\bf defclass}
1)	option is described further on in this section.)
1)	The wording of the above cases mentions one subclass and one superclass,
  1) CONCEP.TEX[CLS,LSP] and 2) CONCEP.8[CLS,LSP]	1-16-87 12:39	pages 1,1

1)	but a class often has more than one superclass.   The class precedence
1)	order is used to determine how the slots are inherited.  When a class is
1)	defined, the slots that it will be able to access are determined by
1)	considering each local slot-description, and the description of each
1)	slot that is given by the most specific superclass in the class
1)	precedence list.   The examples further on in this section should
1)	clarify this behavior.
1)	\endsubSection%{Inheritance of Slots}
1)	\beginsubSection{Inheritance of DEFCLASS Options}
1)	Inheritance of Slot-options: 
1)	{\bf :accessor} -- This option is not inherited; that is, subclasses do not 
1)	automatically generate methods for accessing a slot unless the {\bf :accessor} 
1)	prefix is specified in the local description.   However, a subclass does  
1)	inherit the methods generated by this option, in the sense that the 
1)	methods are applicable for instances of the subclass.   Because these
1)	methods are primary methods, when standard method combination is used
1)	the subclass can shadow the inherited methods by providing more specific
1)	methods, either by using the {\bf :accessor} option or using {\bf defmethod}.   The
1)	type of inheritance described here also applies to the methods generated
1)	by the {\bf :reader}, {\bf :accessor-prefix}, and {\bf :reader-prefix} options.
1)	{\bf :reader} -- This slot option is not inherited; see the description of the
1)	{\bf :accessor} slot-option.
1)	{\bf :allocation} -- This option is not inherited by subclasses.  However, if 
1)	a local slot description is given for a slot with the same name as a
1)	slot provided by a superclass, this option affects the inheritance of
1)	the slot.  The semantics of slot inheritance and the {\bf :allocation} option
1)	are described above.
1)	{\bf :initform} -- The {\bf :initform} 
1)	option is inherited, and can be overridden in 
1)	a straightforward way.  In the case of an inherited {\bf :instance} slot, if
1)	the {\bf :initform} option is given in a local description, the local
1)	{\bf :initform} completely overrides the inherited {\bf :initform}.
1)	{\bf :type} -- The {\bf :type} option is inherited as follows.   When a class is
1)	being defined, the slot descriptions of all of its superclasses
1)	(including itself) are considered, regardless of the allocation of the
1)	slot. The type of the value of the slot is constrained to satisfy all of
1)	the type constraints given in the descriptions of each of its
1)	superclasses, including itself.  That is, if T1, T2 and so on are the
1)	type constraints given by the class and all of its superclasses, the
1)	value of the slot must satisfy (typep value '(and T1 T2 T3...).  [This 
1)	inheritance behavior allows a compiler to optimize on the basis of the
1)	{\bf :type} option in the {\bf defclass} form.   Some operations can be improved,
1)	when the slot directly is involved in an arithmetic expression, such as
1)	being able to emit the machine addition instruction with only overflow
1)	checking.]
1)	Inheritance of Class Options:
1)	{\bf :accessor-prefix} -- This slot option is not inherited; see the
1)	description of the {\bf :accessor} slot-option. 
  1) CONCEP.TEX[CLS,LSP] and 2) CONCEP.8[CLS,LSP]	1-16-87 12:39	pages 1,1

1)	{\bf :reader-prefix} -- This slot option is not inherited; see the description
1)	of the {\bf :accessor} slot-option.
1)	{\bf :constructor} -- This option has no effect on subclasses; it is not
1)	inherited.   
1)	{\bf :documentation} -- This option has no effect on subclasses; it is not
1)	inherited.  
1)	{\bf :metaclass} -- This option has no effect on subclasses; it is not
1)	inherited.
1)	\endsubSection%{Inheritance of DEFCLASS Options}
1)	\beginsubSection{Examples of Inheritance}
1)	\screen!
1)	(defclass C1 () ((S1 :initform 5.4 :type number) 
1)	                 (S2 :allocation :class))
1)	(defclass C2 (C1) ((S1 :initform 5 :type integer)
1)	                   (S2 :allocation :instance)
1)	                   (S3 :accessor C2-S3))
1)	  :reader-prefix C2-) 
1)	(defclass C3 (C2) ((S2 :allocation :none))) 
1)	\endscreen!
1)	C1 has an {\bf :instance} slot named S1, whose default initial value is 5.4, 
1)	and whose value is constrained to be a number.   C1 also has a {\bf :class} 
1)	slot named S2.
1)	C2 has access to an {\bf :instance} slot named S1, whose default initial value 
1)	is 5, and whose value is constrained to satisfy 
1)	(typep value '(and integer number)).  
1)	C2 has access to two {\bf :instance} slots, named S1 and
1)	S2.  C2 has methods defined for reading the value  
1)	of its slots; these methods are for the generic functions named:  C2-S1,
1)	C2-S2, and C2-S3.  There is also a SETF method for use with C2-S3.
1)	C3 has access to an {\bf :instance} slot named S1, whose default initial value
1)	is 5, and whose value is constrained to satisfy (typep value '(AND
1)	integer number)).  C3 also has access to a slot named S3.  C3 has  
1)	methods applicable for reading the value of the slots S1, S2, and S3.  
1)	Note that although C3 has a method for reading the value of slot S2, it 
1)	does not have access to that slot, so using the method would result in 
1)	an error.  
1)	\endsubSection%{Examples of Inheritance}
1)	\endSection{Inheritance}
1)	\beginSection{Generic Functions and Methods}
**** File 2) CONCEP.8[CLS,LSP]/1P/727L
2)	\beginSection{Generic Functions and Methods}
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1026L
1)	Methods can have qualifiers, which give the method combination procedure
1)	a way to distinguish between methods.  If a method has one or more
1)	qualifiers it is called a qualified or auxiliary method.  An unqualified
  1) CONCEP.TEX[CLS,LSP] and 2) CONCEP.8[CLS,LSP]	1-16-87 12:39	pages 1,1

1)	method is called a primary method.  A qualifier is any object other than
1)	a list; in other words, any non-{\bf nil} atom.  By convention,
1)	qualifiers are usually keyword symbols.
1)	\endsubSection%{Introduction to Methods}
**** File 2) CONCEP.8[CLS,LSP]/1P/854L
2)	Methods can have qualifiers, which give the method combination procedure a
2)	way to distinguish between methods.  If a method has one or more qualifiers
2)	it is called a qualified method, otherwise it is called an unqualified
2)	method.  A qualifier is any object other than a list; in other words, any
2)	non-{\bf nil} atom.  By convention, qualifiers are usually keyword symbols.
2)	\endsubSection%{Introduction to Methods}
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1157L
1)	and all applicable methods are primary, the effective method is the 
1)	most specific method.  That method can call the next most specific method
**** File 2) CONCEP.8[CLS,LSP]/1P/984L
2)	and all applicable methods are unqualified, the effective method is the 
2)	most specific method.  That method can call the next most specific method
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1294L
1)	next most specific {\bf :around} method is executed, if one is applicable.
1)	\item{\bull} If there are no {\bf :around} methods at all, or if {\bf
**** File 2) CONCEP.8[CLS,LSP]/1P/1121L
2)	next most specific {\bf :around} method is executed, if one is available.
2)	\item{\bull} If there are no {\bf :around} methods at all, or if {\bf
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1310L
1)	signalled if {\bf call-next-method} is used and there is no applicable primary method
1)	to call.
1)	\itemitem{--} All the {\bf :after} methods are executed in
**** File 2) CONCEP.8[CLS,LSP]/1P/1137L
2)	signalled if {\bf call-next-method} is used and there is no primary method
2)	available to call.
2)	\itemitem{--} All the {\bf :after} methods are executed in
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1607L
1)	{\bf :most-specific-last} reverses the order of the primary methods, without 
1)	affecting the order of the auxiliary methods.  Use 
1)	the {\bf (:method-combination {\it name\/} :most-specific-last)} 
1)	option to {\bf defgeneric-options} or {\bf defgeneric-options-setf}
  1) CONCEP.TEX[CLS,LSP] and 2) CONCEP.8[CLS,LSP]	1-16-87 12:39	pages 1,1

1)	to specify this. 
1)	This alternate syntax of {\bf define-method-combination} is 
1)	recognized when the second subform is a non-{\bf nil} 
1)	symbol.  A large fraction of the types of method combination needed by 
1)	most programmers can be implemented with this short form, which is 
1)	provided for convenience.   The short form automatically includes 
1)	error-checking and support for {\bf :around} methods, thus saving the
1)	programmer from writing that code, and avoids the need for the programmer to
1)	use the backquote and comma, and learn the more complex syntax of the long form.
1)	%This was a previous wording.   I left it around because I'm
1)	%still thinking about it.   -Sonya 
1)	%This alternate syntax of {\bf define-method-combination} is provided for
1)	%convenience and is recognized when the second subform is a non-{\bf nil}
1)	%symbol.  A large fraction of the types of method combination defined by
1)	%most programmers can be implemented with this short form.  Using the short
1)	%form avoids the ``scariness'' of the long form to new programmers, 
1)	%removes the bother of using backquote and comma correctly, and
1)	%eliminates the temptation to omit error checking and support for
1)	%{\bf :around} methods.
1)	Example:
**** File 2) CONCEP.8[CLS,LSP]/1P/1434L
2)	{\bf :most-specific-last} reverses the order of the primary methods, without
2)	affecting the order of the auxiliary methods.  Use
2)	the {\bf (:method-combination {\it name\/} :most-specific-last)}
2)	option to {\bf defgeneric-options} or {\bf defgeneric-options-setf}
2)	to specify this.
2)	This alternate syntax of {\bf define-method-combination} is provided for
2)	convenience and is recognized when the second subform is a non-{\bf nil}
2)	symbol.  A large fraction of the types of method combination defined by
2)	most programmers can be implemented with this short form.  Using the short
2)	form avoids the ``scariness'' of the long form to new programmers,
2)	removes the bother of using backquote and comma correctly, and
2)	eliminates the temptation to omit error checking and support for
2)	{\bf :around} methods.
2)	Example:
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1646L
1)	(DEFINE-METHOD-COMBINATION name lambda-list                     [macro] 
1)	      ( {(variable { {qualifier-pattern}+ | predicate}
**** File 2) CONCEP.8[CLS,LSP]/1P/1462L
2)	(DEFINE-METHOD-COMBINATION name lambda-list                     [macro]
2)	      ( {(variable { {qualifier-pattern}+ | predicate}
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1685L
  1) CONCEP.TEX[CLS,LSP] and 2) CONCEP.8[CLS,LSP]	1-16-87 12:39	pages 1,1

1)	(which matches primary methods, which are always unqualified), 
1)	the symbol {\bf *} (which matches all
1)	methods), a true list (which matches methods with the same number of
**** File 2) CONCEP.8[CLS,LSP]/1P/1501L
2)	(which matches unqualified methods), the symbol {\bf *} (which matches all
2)	methods), a true list (which matches methods with the same number of
***************


**** File 1) CONCEP.TEX[CLS,LSP]/1P/1731L
1)	method-group includes the primary methods.
1)	The argument {\it format-string\/} is not evaluated.
**** File 2) CONCEP.8[CLS,LSP]/1P/1546L
2)	method-group includes the unqualified methods.
2)	The argument {\it format-string\/} is not evaluated.
***************